package com.ddch.udpsocket.activity;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;

import com.ddch.udpsocket.R;
import com.ddch.udpsocket.socket.SocketManager;
import com.google.android.material.floatingactionbutton.FloatingActionButton;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * created by 韦敏敏
 * on 2019/12/23
 */
public class TcpSocketActivity extends AppCompatActivity {
    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.fab)
    FloatingActionButton fab;
    private SocketManager manager;
   private  Unbinder unbinder;
   private Handler uiHandler = new Handler(){
       @Override
       public void handleMessage(Message msg) {

       }
   };
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_tcp_socket);
       unbinder = ButterKnife.bind(this);
        manager = SocketManager.getInstance(this, uiHandler);
        manager.startUdpConnection();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        manager.stopSocket();
        unbinder.unbind();
    }
}
